﻿using FluentNHibernate.Mapping;
using YunBox2.Contracts.FoundationModels;

namespace YunBox2.DAL.Maps
{
    public class CartonTypeMap : ClassMap<CartonType>
    {
        public CartonTypeMap()
        {
            Id(x => x.Id).GeneratedBy.Guid().Default("(newid())");
            Map(x => x.Name).Length(64).Not.Nullable();

            HasMany(x => x.Parts).KeyColumn("ContonTypeId").Cascade.All().OrderBy("LastModifiedTime asc");

            Map(x => x.LastModifiedTime).Not.Nullable();
            References(x => x.LastModifiedUser).Column("LastModifiedUserID").Not.Nullable();
            Table("CartonType");
        }
    }

    public class CartonTypePartMap : ClassMap<CartonTypePart>
    {
        public CartonTypePartMap()
        {
            Id(x => x.Id).GeneratedBy.Guid().Default("(newid())");

            Map(x => x.LengthExpression).Length(250).Not.Nullable();
            Map(x => x.WidthExpression).Length(250).Not.Nullable();
            Map(x => x.Amount).Not.Nullable();

            Map(x => x.LastModifiedTime).Not.Nullable();
            References(x => x.LastModifiedUser).Column("LastModifiedUserID").Not.Nullable();
            Table("CartonTypePart");
        }
    }
}